<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_CreateTable_User extends CI_Migration
{
    public function up()
    {
        $this->dbforge->add_field('id');
        $this->dbforge->add_field(array(
            'email'           => array('type' => 'VARCHAR', 'constraint' => '100',),
            'nickname'        => array('type' => 'VARCHAR', 'constraint' => '10',),
            'password'        => array('type' => 'VARCHAR', 'constraint' => '60',),
            'salt'            => array('type' => 'CHAR', 'constraint' => '5',),
            'power'           => array('type' => 'INT', 'constraint' => '5', 'default' => '0'),
            'reg_ip'          => array('type' => 'VARCHAR', 'constraint' => '20',),
            'reg_time'        => array('type' => 'DATETIME',),
            'login_ip'        => array('type' => 'VARCHAR', 'constraint' => '20', 'null' => TRUE,),
            'login_time'      => array('type' => 'DATETIME', 'null' => TRUE,),
            'act_ip'          => array('type' => 'VARCHAR', 'constraint' => '20', 'null' => TRUE,),
            'act_time'        => array('type' => 'DATETIME', 'null' => TRUE,),
            'user_info_id'    => array('type' => 'INT', 'constraint' => '9', 'null' => TRUE,),
            'student_info_id' => array('type' => 'INT', 'constraint' => '9', 'null' => TRUE,),
        ));
        $this->dbforge->create_table('user');
        $this->db->simple_query('ALTER TABLE user ADD UNIQUE (email)');
    }

    public function down()
    {
        $this->dbforge->drop_table('user');
    }
} 